
/* SCREEN */
	#define STRING_MAXLENGTH 40
	#define MARGIN_LEFT 10
	#define MARGIN_LEFT_CLOCK 270
	#define MARGIN_LEFT_DATE  166
	#define MARGIN_RIGHT 10
	#define MARGIN_TOP 5
	#define MAX_LINES 7
	#define LINE_HEIGHT 20

	#define ERROR_MARGIN_TOP 5

	#define CHARACTER_WIDTH 8

/* HEADER/HEADING CONSTANTS */
	#define HEADER_HEIGHT 30
	#define HEADING_COLOR WHITE
	#define HEADING_BGCOLOR BLUE
	#define HEADING_MARGIN_BOTTOM 10
	#define HEADING_LABEL_OFFSET 6

	#define HEADER_MODE_CLOCK 0
	#define HEADER_MODE_BACK 1

	#define HEADER_BACK_BTN_WIDTH 40
	#define HEADER_BACK_BTN_HEIGHT 20
	#define HEADER_BACK_BTN_MARGIN_TOP 5
	#define HEADER_BACK_BTN_LABEL_OFFSET 5
	#define HEADER_BACK_BTN_VALUE -6

/* MENU */
	#define MENUBTN_LINE_HEIGHT 25
	#define MENUBTN_LABEL_OFFSET 6
	#define MENUBTN_COLOR WHITE
	#define MENUBTN_MARGINTOP 10
	#define MENU_MARGINTOP 5

/* CONFIRM DIALOG */
	#define CONFIRM_BTN_WIDTH 50
	#define CONFIRM_BTN_HEIGHT 30
	#define CONFIRM_BTN_MARGIN_TOP 120
	#define CONFIRM_BTN_MARGIN_LEFT 115

/* KEYBOARD 
 * 0-9 equals value 0-9
 * -2: Delete last sign
 * -3: Accept
 * -5: No Value
 */

		#define KB_DEL -1
		#define KB_ACC -2

	/* MODES
	 * integer: 0-60[ml]
	 * interval: [0-23]:[0-59]
	 * date: [0-31].[0-12].20[0-99]
	 * time: [0-23]:[0-59]
	 */
		#define KB_MODE_INTEGER 0
		#define KB_MODE_INTERVAL 1
		#define KB_MODE_DATE 2
		#define KB_MODE_TIME 3
	
	/* RETURN VALUES
	 * uint8 arr[n] (valid input)
	 * 15: input invalid
	 */		
	 	#define KB_RETURN_ABORT -1

	/* DIMENSIONS */
		#define KB_BTN_WIDTH 60
		#define KB_BTN_HEIGHT 35
		#define KB_BTN_MARGIN 2
		#define KB_BTN_PADDING_TOP 10
		#define KB_BTN_PADDING_LEFT 27
		#define KB_BTN_INAROW 3
		#define KB_MARGIN_LEFT 70
		#define KB_MARGIN_TOP 60
		#define KB_FORMAT_OFFSET 40

	//SLOT PARAMETER SCREEN
	#define SLOT_BTN_HEIGHT 35
	#define SLOT_BTN_WIDTH 40
	#define SLOT_BTN_MARGIN 3
	#define SLOT_BTN_PADDING_TOP 10
	#define SLOT_BTN_PADDING_LEFT 15

	#define SETTINGS_BTN_WIDTH 80
	#define SETTINGS_BTN_HEIGHT 23
	#define SETTINGS_BTN_MARGIN 4
	#define SETTINGS_BTN_PADDING_LEFT 30
	#define SETTINGS_BTN_PADDING_TOP 5

	//ACTIVATION BUTTONS FOR SLOTS
	#define SETTINGS_BTN_ACTIVE_PADDING_LEFT 8

	#define SETTINGS_BTN_INTERVAL -1
	#define SETTINGS_BTN_DOSE -2
	#define SETTINGS_BTN_FILL_LVL -3
	#define SETTINGS_BTN_ACTIVE_YES -4
	#define SETTINGS_BTN_ACTIVE_NO -5

	//MAIN SCREEN
	#define SLOT_WIDTH 34
	#define SLOT_HEIGHT 120
	#define SLOT_PADDING_LEFT 10
	#define SLOT_MARGIN_BOTTOM 5
	#define SLOT_LABEL_CENTER 16


/* GLOBALS, COMMON GUI VARS */
	uint8 active_line;
	char string[STRING_MAXLENGTH];
	
void GUI_init();
uint8 GUI_getLineHeight(uint8 items);
uint8 GUI_getStartingPos();
void GUI_writeLine(unsigned char* txt, unsigned int fontColor);
void GUI_overwriteLine(uint8 line, unsigned char* txt, unsigned int fontColor);
void GUI_setHeader(unsigned char* txt, uint8 mode);
void GUI_setColor(unsigned int color, uint16 startingPointX, uint16 startingPointY, uint16 rangeX, uint16 rangeY);
void GUI_showScreen(uint8 screen);

	/* GUI_drawBox:
	   Inverted display directions

		x=0,y=0				  x=320,y=0
			 ----------------------
			|                      |
			|                      |
			|                      |
			|                      |
			|                      |
			|                      |
			 ----------------------
		x=0,y=240		      x=320,y=240
	*/
	void GUI_drawBox(uint16 startX, uint16 startY, unsigned int width, unsigned int height, unsigned int color);

	uint8 GUI_confirm(unsigned char* txt);

	//Keyboard API
	void GUI_showKeyboard(unsigned char* txt, uint8 mode, int8 * input);

	/*	GUI_kbResetInput:
		Resets the input array as well as the input format
		string, both initialized by 0.
		
		Parameters:

			* count_input: number of total inputs from keyboard
			* input: pointer to uint8 array to which the input values
				     will be written
			mode: current keyboard mode, possible values [GUI.H] are
					->KB_MODE_INTERVAL	(expects interval "hhh.mm")
					-> KB_MODE_INTEGER	(two digits)
					-> KB_MODE_DATE 	(expects date "dd.mm.[20]yy")
					-> KB_MODE_TIME		(the time "hh:mm")
	*/
	void GUI_kbResetInput(uint8 * count_input, int8 * input, uint8 mode);
	void GUI_kbShowFormat(uint8 mode);
	void GUI_evalKeyboard(int8 * key);
	
	//CLOCK FUNCTIONS
	void GUI_showTimeLeft();
	void GUI_showClock();

	//PARAMS SCREEN
	void GUI_showSlotDetails(uint8 slot);
	void GUI_showSlotSettings(uint8 slot);
	void GUI_showSlotActivation(uint8 slot);
	void GUI_showSlotMenu(uint8 active_slot);
	uint8 GUI_evalSlotMenu(uint8 active_slot);
	void GUI_slotClicked(uint8 selected_slot, uint8 active_slot);
	void GUI_screen_params(uint8 active_slot);

	void GUI_showErrorLog();

